Skip to content

refactor(shapes): extract shared renderDataLabels utility#553

Merged
kuzmadom merged 2 commits intomainfrom
data-labels-refactor
Apr 14, 2026
Merged

refactor(shapes): extract shared renderDataLabels utility#553
kuzmadom merged 2 commits intomainfrom
data-labels-refactor

Conversation

@kuzmadom
Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the repeated D3 label rendering block (10+ copies) into a single
    renderDataLabels function in src/core/shapes/data-labels.ts
  • Covers: bar-x, bar-y, line, area, waterfall, radar, funnel, heatmap, sankey, x-range
  • Returns a typed D3 selection so callers can chain extra attributes and use it
    in hover handlers

Bug fixes (found during refactor)

  • funnel, heatmaptext-anchor was never applied; now consistent with all other shapes
  • sankeyfont-weight was missing; fill was set via attr() instead of style()
    (CSS wins over SVG attribute, so style() is correct everywhere)
  • heatmap — added textAnchor field to HeatmapLabel type and populated it in
    prepare-data ('start', since x is already manually offset to center the text)

Not included

treemap — uses a custom TreemapLabelData type without per-label style,
reads style from series.dataLabels.style directly. Aligning it is a separate task.

@gravity-ui-bot
Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 14, 2026

📖 Docs Preview is ready.

@gravity-ui
Copy link
Copy Markdown

gravity-ui bot commented Apr 14, 2026

Visual Tests Report is ready.
Performance Tests Report is ready.

@kuzmadom kuzmadom marked this pull request as ready for review April 14, 2026 13:39
@kuzmadom kuzmadom requested a review from korvin89 as a code owner April 14, 2026 13:39
@kuzmadom kuzmadom merged commit 8b339b9 into main Apr 14, 2026
6 checks passed
@kuzmadom kuzmadom deleted the data-labels-refactor branch April 14, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants